<!doctype html>
<html>
    <head>
        <title>快速排序</title>
        <meta charset="utf-8" />
    </head>
    <body>
       <script src="../defun.js"></script> 
       <script>
        var sort = defun({
            "[]":[],
            "(x:xs)":(x,xs)=>sort(xs.filter(a=>a<x)).concat(x).concat(sort(xs.filter(a=>!(a<x))))
        });
        document.write("<h3>快速排序[1,2,3,4,5]</h3>");
        document.write(sort([1,2,3,4,5]));
        document.write("<h3>快速排序[18,21,88,4,5]</h3>");
        document.write(sort([18,21,88,4,5]));
       </script>
    </body>
</html>
